/*
 * Copyright (c) 2018. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.j4dream.property.dao;

import com.j4dream.property.BaseDaoTestCase;
import com.j4dream.property.model.PermissionDto;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static org.junit.Assert.*;

public class PermissionDaoTestCase extends BaseDaoTestCase {
    @Autowired
    private PermissionDao permissionDao;

    @Test
    public void insertPermission() {
        permissionDao.insertPermission(new PermissionDto("TEST_PERM_1", "For test."));
        permissionDao.insertPermission(new PermissionDto("TEST_PERM_2", "For test."));

        assertEquals(2, permissionDao.getPermList().size());
    }

    @Test
    public void getPermList() {
        permissionDao.insertPermission(new PermissionDto("TEST_PERM_CREATE", "test create perm"));
        permissionDao.insertPermission(new PermissionDto("TEST_PERM_UPDATE", "test update perm"));
        List<PermissionDto> permissionDaos = permissionDao.getPermList();
        assertEquals("TEST_PERM_CREATE", permissionDaos.get(0).getName());
        assertEquals("test create perm", permissionDaos.get(0).getDescription());

        assertEquals("TEST_PERM_UPDATE", permissionDaos.get(1).getName());
        assertEquals("test update perm", permissionDaos.get(1).getDescription());
    }
}